package org.jeecg.api.dto.req;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import springfox.documentation.annotations.ApiIgnore;

import javax.validation.constraints.NotNull;

@Data
public class PageReq {
    /**
     * 当前页数
     */
    @NotNull(message = "当前页数不能为空")
    @ApiModelProperty("当前页数")
    private Integer page = 1;

    /**
     * 每页大小
     */
    @NotNull(message = "每页大小不能为空")
    @ApiModelProperty("每页大小")
    private Integer pageSize = 10;

    /**
     * 获取offset
     *
     * @return
     */
    @ApiIgnore
    public Integer getOffset() {
        return (page - 1) * pageSize;
    }

}
